package controllers

import (
	"github.com/astaxie/beego"
	//"fmt"
	"beego/testApp/common"
	"time"

	
)

type AddMenuController struct {
	beego.Controller
}

func (c *AddMenuController) Get() {

	 mname := c.GetString("mname")
	 url   := c.GetString("url")
	 sort,_  := c.GetInt("sort")

	 now := time.Now()

	 if(mname!="" && url!="" && sort!=0){
		menonj := &common.Menu{Mname:mname,Url:url,Sort:sort,Created:now}
		ckmenuadd := menonj.Add()
		if(ckmenuadd == true){
			c.Redirect("/admin/menulist",301);
		}
	 }
	 

	c.TplName = "addmenu.html"
}
